package
{
	import com.GlobalConfig;
	import com.Remoting;
	import com.phpnet.*;
	
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.text.TextField;

	public class Main extends Sprite
	{
		private var _globalParam:GlobalConfig = null;
		private var _pr:Object;
		private var _textField:TextField=null;
		public function Main()
		{
			if (stage) addToStageHandler();
			else	
				addEventListener(Event.ADDED_TO_STAGE, addToStageHandler);
		}
		
		/**
		 * loading.swf加载成功，并添加到舞台
		 * @param	e
		 */
		private function addToStageHandler(e:Event = null):void 
		{
			_globalParam = GlobalConfig.instance;
			_globalParam.loaderInfo = root.loaderInfo;
			_pr= root.loaderInfo.parameters;

			_globalParam.mid = checkParams('uid') ? _pr.uid : 0;
			
			_globalParam.sid=checkParams('pfid') ? _pr.pfid : 1;
			_globalParam.mtkey = checkParams('olkey') ? _pr.olkey : "";//平台id
			_globalParam.unid = checkParams('usid') ? _pr.usid : '';//子站点id
			_globalParam.langtype = checkParams('lang') ? _pr.lang : '';//语言类型			
			_globalParam.gateway = checkParams('gwurl') ? _pr.gwurl : '';
			_globalParam.tid = checkParams('tid') ? _pr.tid : 0;//桌子id
			
			_globalParam.pic = checkParams('uface') ? _pr.uface : '';//头像地址
			_globalParam.basUrl = checkParams('baseurl') ? _pr.baseurl : '';//首地址
			_globalParam.gateway= checkParams('gwurl') ? _pr.gwurl : '';//首地址
			_globalParam.flashurl= checkParams('swfurl') ? _pr.swfurl : '';//加载swf地址
			_globalParam.xmlurl= checkParams('xmlurl') ? _pr.xmlurl : '';//加载swf地址
			_globalParam.imgurl= checkParams('imgurl') ? _pr.imgurl : '';//加载图片地址
			_globalParam.xver= checkParams('xver') ? _pr.xver : '';//加载图片地址
			_globalParam.swfver= checkParams('fver') ? _pr.fver : '';//加载图片地址
			
			var textt:String="mid:"+_globalParam.mid+"sid"+_globalParam.sid+"mtkey:"+_globalParam.mtkey;
			
			_textField=new TextField();
			
			_textField.text=textt;
			_textField.textColor=0xff0000;
			this.addChild(_textField);
			testHandler();
		}
		
		// 检测网页参数是否已定义.已定义为true
		private function checkParams(str:String):Boolean{
			return typeof(_pr[str]) != 'undefined';
		}
		
		private function testHandler():void
		{
			Remoting.instance.nuTables.getAllTables(0,0);
		}
	}
}0